<template>
  <!-- <sub-page title="岗位详情" v-model:show="showDetail"> -->
  <div class="app-container">
    <el-form ref="formRef" :model="form" label-width="100px">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="产线编号" prop="code">
            {{ form.code }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="产线名称" prop="name">
            {{ form.name }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="工厂" prop="factoryName">
            {{ form.factoryName }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="工段" prop="workshopName">
            {{ form.workshopName }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="产线负责人" prop="ownerName">
            {{ form.ownerName }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="备注" prop="remark">
            <el-tooltip class="box-item" effect="dark" :content="form.remark" placement="top-start">
              <p style=" margin: 0;overflow: hidden; text-overflow: ellipsis; white-space: nowrap">
                {{ form.remark }}
              </p>
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-tabs v-model="activeName" class="demo-tabs">
      <el-tab-pane label="工艺段" name="first">
        <!-- <el-form
          :model="queryParams"
          ref="queryRef"
          :inline="true"
          v-show="showSearch"
          label-width="100px"
        >
          <el-form-item label="工艺段名称" prop="segmentName">
            <el-input
              v-model="queryParams.segmentName"
              placeholder="请输入工艺段名称"
              clearable
              style="width: 240px"
              @keyup.enter="handleQuery"
            />
          </el-form-item>

          <el-form-item>
            <el-button type="primary" icon="Search" @click="handleQuery"
              >搜索</el-button
            >
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
          <right-toolbar
            v-model:showSearch="showSearch"
            @queryTable="getList"
          ></right-toolbar>
        </el-row> -->

        <el-table :data="tableData" border>
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="工艺段编号" align="center" prop="sectionCode"></el-table-column>
          <el-table-column
            label="工艺段名称"
            align="center"
            prop="sectionName"
            :show-overflow-tooltip="true"
          />
        </el-table>

        <pagination
          v-show="total > 0"
          :total="total"
          v-model:page="queryParams.pageNum"
          v-model:limit="queryParams.pageSize"
          @pagination="getList"
        />
      </el-tab-pane>
    </el-tabs>
  </div>
  <!-- </sub-page> -->
</template>

<script setup name="Data">
import { getProdLine } from "@/api/base/prodLine";
import { listProdSection } from "@/api/base/processSection";
import { ref, toRefs, reactive, useAttrs, onMounted } from "vue";
const activeName = ref("first");
const attrs = useAttrs();
// const props = defineProps(["data"]);
const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
  },
});
const tableData = ref([]);
const total = ref(0);
const formRef = ref(null);
const { form, queryParams } = toRefs(data);

function getDetail(id) {
  reset();
  getProdLine(id).then((res) => {
    form.value = res.data;
    queryParams.value.productLine = form.value.code;
    getList();
  });
}

function getList() {
  listProdSection(queryParams.value).then((response) => {
    tableData.value = response.rows;
    total.value = response.total;
  });
}

/** 表单重置 */
function reset() {
  form.value = {
    name: undefined,
    type: undefined,
    equipNo: undefined,
    model: undefined,
    factory: undefined,
    segmentCode: undefined,
    workshopCode: undefined,
    status: undefined,
    remark: undefined,
  };
  formRef.value.resetFields();
}
onMounted(async () => {
  const { data } = attrs;
  getDetail(data.id);
});
</script>
